# 引入模块
import unittest
import HTMLTestRunnerPlugins
import datetime

# 1. 确定case路径
case_path = "./case"
# 2. 确定报告的路径
now_date = datetime.datetime.strftime(datetime.datetime.now(), "%Y%m%d%H%M%S")
report_path = f"./report/{now_date}.html"
# 3. 创建一个测试套件对象
my_suite = unittest.defaultTestLoader.discover(case_path)
# 4. 执行
with open(report_path, "wb") as fp:
    # 创建执行对象
    my_runner = HTMLTestRunnerPlugins.HTMLTestRunner(
        stream=fp,
        title="ECShop自动化测试用例报告",
        description="报告相关可联系测试部:",
        tester="组员:"
    )
    my_runner.run(my_suite)

